<template>
  <div class="house-item">
    <div class="item-inner">
      <div class="cover">
        <img :src="itemData.image.url" alt="" />
      </div>
      <div class="tag">优选PRO</div>
      <div class="info">
        <div class="summaryText">{{ itemData.summaryText }}</div>
        <div class="houseName">
          {{ itemData.houseName }}
        </div>
        <div class="price">
          <van-rate
            readonly
            allow-half
            :count="5"
            v-model="commentScore"
            :size="15"
            color="#fff"
            void-icon="star"
            void-color="rgba(0,0,0,0.5)"
          />
          <div class="new">￥{{ itemData.finalPrice }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
const data = defineProps({
  itemData: {
    type: Object,
    default: () => ({}),
  },
});
const commentScore = parseFloat(data.itemData.commentScore);
</script>

<style lang="less" scoped>
.house-item {
  position: relative;
  width: 48%;
  margin: 4px 0;
  border-radius: 10px;
  overflow: hidden;
  .cover {
    position: relative;
    img {
      width: 100%;
    }
  }
  .tag {
    position: absolute;
    top: 5px;
    left: 5px;
    border-radius: 10px;
    padding: 2px 6px;
    background-color: #fff;
  }
  .info {
    position: absolute;
    bottom: 0;
    padding: 10px;
    color: #fff;
    height: 40%;
    .summaryText {
      font-size: 12px;
    }
    .price {
      display: flex;
      justify-content: space-around;
      .new {
        font-size: 16px;
      }
    }
    .houseName {
      width: 100%;
      font-size: 16px;
      word-break: break-all;
      text-overflow: ellipsis;
      overflow: hidden;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2; /* 这里是超出几行省略 */
      margin: 6px 0;
    }
  }
}
</style>
